﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dukou.BizService.Impl;
using Dukou.WebSiteDesigner.Dao;
using Dukou.WebSiteDesigner.Domain;
using Spring.Transaction.Interceptor;

namespace Dukou.WebSiteDesigner
{
    public class PageDesigner : BaseBizService<IPageDao, Page, Int64>, IPageDesigner
    {
        public override long Save(Page entity)
        {
            entity.Html = entity.ToHtml();
            entity.UpdateTime = DateTime.Now;
            return base.Save(entity);
        }

        [Transaction(ReadOnly=false)]
        public override void SaveOrUpdate(Page entity)
        {
            DateTime now = DateTime.Now;
            if (now != entity.UpdateTime)
            {
                entity.Html = entity.ToHtml();
                entity.UpdateTime = now;
            }

            base.SaveOrUpdate(entity);
        }
    }
}
